package com.mzz.creational.prototype;

import java.io.IOException;

public class Test {

    public static void main(String[] args) throws IOException, ClassNotFoundException {
        //测试浅复制的

        //创建一个对象
        PrototypeShallowCopy pro = new ConcretePrototypeShallowCopy("浅复制名称");
        //克隆上面的对象，包括其属性
        PrototypeShallowCopy pro2 = (PrototypeShallowCopy) pro.clone();

        System.out.println(pro.getName());//输出prototype
        System.out.println(pro2.getName());//输出prototype

        //========================================================================================================


        //测试深复制的

        //创建一个对象
        ConcretePrototypeDeepCopy pro3 = new ConcretePrototypeDeepCopy("深复制名称", "性别男");
        //克隆上面的对象，包括其属性
        PrototypeDeepCopy pro4 = (PrototypeDeepCopy) pro3.deepClone();

        System.out.println(pro4.getName());
        System.out.println(pro4.getObj().getSex());

    }
}
